export function mapUrlToItem(menu, currentUrl) {
    if (!menu) return;
    for (let i = 0; i < menu.length; i++) {
        if (menu[i].routePath === currentUrl) {
            return menu[i];
        } else {
            const find = mapUrlToItem(menu[i].child, currentUrl);
            if (find) return find;
        }
    }
}
export function mapIdToItem(menu, id) {
    if (!menu) return;
    for (let i = 0; i < menu.length; i++) {
        if (menu[i].id === id) {
            return menu[i];
        } else {
            const find = mapIdToItem(menu[i].child, id);
            if (find) return find;
        }
    }
}
export function mapMenusToRoutes(menus, routes) {
    const mapRoutes = [];
    function _recursionMenus(menus) {
        menus.forEach((item) => {
            if (item.child.length !== 0) {
                const findRoute = routes.find((route) => route.path === item.routePath);
                if (findRoute) mapRoutes.push(findRoute);
                _recursionMenus(item.child);
            } else {
                const findRoute = routes.find((route) => route.path === item.routePath);
                if (findRoute) mapRoutes.push(findRoute);
            }
        });
    }
    _recursionMenus(menus);
    return mapRoutes;
}
